package me.zhengjie.modules.system.rest.machine;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.base.Code;
import me.zhengjie.modules.system.domain.req.SysUserBankCardReqDTO;
import me.zhengjie.modules.system.domain.req.SysUserBankCardReqQueryDTO;
import me.zhengjie.modules.system.domain.rsp.SysUserBankCardRspDTO;
import me.zhengjie.modules.system.service.SysUserBankCardService;
import me.zhengjie.utils.PageResult;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wx
 * @email
 * @date 2025-02-14 16:46:35
 */
@RestController
@RequestMapping("/api/sysUserBankCard")
@Api(tags = "银行卡信息")
@RequiredArgsConstructor
public class SysUserBankCardController {

    private final SysUserBankCardService sysUserBankCardService;

    /**
     * 列表
     */
    @ApiOperation(value = "列表")
    @PostMapping("/page")
    public PageResult<SysUserBankCardRspDTO> page(@RequestBody SysUserBankCardReqQueryDTO reqQueryDTO) {
        return sysUserBankCardService.findAll(reqQueryDTO);
    }


    /**
     * 保存
     */
    @ApiOperation(value = "保存")
    @PostMapping("/save")
    public ResponseEntity<Boolean> save(@RequestBody SysUserBankCardReqDTO reqDTO) {
        sysUserBankCardService.save(reqDTO);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改")
    @PostMapping("/update")
    public ResponseEntity<Boolean> update(@RequestBody SysUserBankCardReqDTO reqDTO) {
        sysUserBankCardService.update(reqDTO);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除")
    @PostMapping("/delete")
    public ResponseEntity<Boolean> delete(@RequestBody Code code) {
        sysUserBankCardService.delete(code);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    /**
     * 主键查询
     */
    @ApiOperation(value = "主键查询")
    @PostMapping("/findById")
    public ResponseEntity<Object> findById(@RequestBody Code code) {

        return new ResponseEntity<>(sysUserBankCardService.findById(code), HttpStatus.OK);

    }
}
